import request from '@/request/request'

//用户登录
export const UserLoginServer = (fromDate) => {
    return request.post('/user/login', fromDate)
}

//验证用户名唯一

export const OnlyUserServer = (username) => {
    return request.get('/user/onlyOne', { params: { 'username': username } })
}

//用户注册
export const RegisterUserServer = (fromDate) => {
    return request.post('/user/register', fromDate)
}

//获取用户详情
export const GetUserDetail = () => {
    return request.get('/user/getUserDetail')
}

//获取所有部门分类

export const GetAllDept = () => {
    return request.get('/user/departments')
}

//修改个人信息

export const UpdatePrivateUserServer = (fromDate) => {
    return request.put('/user/updatePrivateUser', fromDate)
}

//获取职业分类
export const GetAllJobs = () => {
    return request.get('/user/jobs')
}

//分页获取数据

export const PageGetUserServer = (from) => {
    const params = new URLSearchParams()
    for (let key in from) {
        params.append(key, from[key])
    }
    return request.get('/user/pageUser', { params: params })
}

//添加员工
export const AddUserServer = (form) => {
    return request.post('/user/addUser', form)
}


//删除员工
export const DeleteUserServer = (username) => {
    return request.delete('/user/delete', { params: username })
}

//修改员工信息
export const UpdateUserServer = (fromDate) => {
    return request.put('/user/updateUser', fromDate)
}
//修改图片
export const UpdateUserAvatar = (image,username) => {
    return request.patch("/user",{image,username})
}
//重置密码
export const ResetPassword = (username) => {
    return request.get('/user/reset', { params: username })
}

//获取用户数据信息
export const GetStatisticsServer = () => {
    return request.get('/user/statistics')
}